package XMLScene;

import java.util.Vector;

import Tracer.RTBitmap;
import Tracer.RTColor;

/**
 * Model class to store pigment data of a surface.
 * 
 * @author forrest lorraine eagle
 */
public class RTPigment {
	/**
	 * the color of surface
	 */
	private RTColor sColor = null;
	/**
	 * the bitmap of surface
	 */
	private RTBitmap sBitmap = null;
	/**
	 * @param color
	 *            We use static here because we only need one instance of them
	 *            across all RTPigment instance. The sbitmapList is the
	 *            imagePool for buffering PPM images.
	 */
	private static Vector<RTBitmap> sBitmapList = new Vector<RTBitmap>();
	private static Vector<String> sBitmapListTag = new Vector<String>();

	public RTPigment(final RTColor color) {
		sColor = new RTColor(color);
	}

	/**
	 * @param path
	 */
	public RTPigment(final String path) {
		if (sBitmapListTag.contains(path)) {
			sBitmap = sBitmapList.elementAt(sBitmapListTag.indexOf(path));
		} else {
			sBitmap = new RTBitmap();
			sBitmap.readFromPPM(path);
			sBitmapList.add(sBitmap);
			sBitmapListTag.add(path);
		}
	}

	/**
	 * @return the pure color of surface
	 */
	public final RTColor getColor() {
		return sColor;
	}

	/**
	 * @return the bitmap of the surface
	 */
	public final RTBitmap getBitmap() {
		return sBitmap;
	}
}